package com.snk.back.controller;

import com.snk.back.service.SysMenuService;
import com.snk.common.utils.ShiroUtils;
import com.snk.pojo.SysUser;
import com.snk.pojo.SysUserMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@RequestMapping("/")
@Controller
public class PageController {
  @Autowired
    private SysMenuService sysMenuService;

    @RequestMapping("doIndexUI")
    public String doIndexUI(Model model){
        SysUser user= ShiroUtils.getUser();
        model.addAttribute("username", user.getUsername());
        List<SysUserMenu> userMenus=
                sysMenuService.findUserMenusByUserId(user.getId());
        model.addAttribute("userMenus", userMenus);
        return "starter";
    }


    @RequestMapping("{module}/{moduleUI}")
    public String doModuleUI(@PathVariable String moduleUI) {
        return "sys/"+moduleUI;
    }


    @RequestMapping("doPageUI")
    public String doPageUI(){
        return "common/page";
    }

    @RequestMapping("doLoginUI")
    public String doLoginUI(){
        return "login";
    }



}
